//
//  CLUIBaseTableViewController+Empty.m
//  JiuLe
//
//  Created by 黄鑫 on 2016/10/28.
//  Copyright © 2016年 Fine. All rights reserved.
//

#import "CLUIBaseTableViewController+Empty.h"
#import <objc/runtime.h>

static char imageEmptyCategoryStatic;
static char labelEmptyCategoryStatic;
@implementation CLUIBaseTableViewController (Empty)

- (void)showLabelEmptyCate:(CGRect)frame withTitle:(NSString *)title withImage:(UIImage *)image{
    self.imageEmptyCategory = [[UIImageView alloc] initWithFrame:frame];
    self.imageEmptyCategory.image = image;
    [self.tableView addSubview:self.imageEmptyCategory];
    [self.tableView bringSubviewToFront:self.imageEmptyCategory];
    self.labelEmptyCategory = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.imageEmptyCategory.frame), [UIScreen mainScreen].bounds.size.width, 40)];
    self.labelEmptyCategory.textAlignment = NSTextAlignmentCenter;
    self.labelEmptyCategory.textColor = [UIColor grayColor];
    self.labelEmptyCategory.text = title;
    self.labelEmptyCategory.hidden = NO;
    self.labelEmptyCategory.font = [UIFont boldSystemFontOfSize:19];
    [self.tableView addSubview:self.labelEmptyCategory];
    [self.tableView bringSubviewToFront:self.labelEmptyCategory];
}

- (void)clearLabelEmptyCate{
    if (self.labelEmptyCategory.hidden == NO && self.labelEmptyCategory != nil) {
        self.labelEmptyCategory.hidden = YES;
        self.imageEmptyCategory.hidden = YES;
    }
}

#pragma mark - set/get
- (void)setImageEmptyCategory:(UIImageView *)imageEmptyCategory{
    objc_setAssociatedObject(self, &imageEmptyCategoryStatic, imageEmptyCategory, OBJC_ASSOCIATION_RETAIN);
}

- (UIImageView *)imageEmptyCategory{
    return objc_getAssociatedObject(self, &imageEmptyCategoryStatic);
}

- (void)setLabelEmptyCategory:(UILabel *)labelEmpty{
    objc_setAssociatedObject(self, &labelEmptyCategoryStatic, labelEmpty, OBJC_ASSOCIATION_RETAIN);
}


- (UILabel *)labelEmptyCategory{
    return objc_getAssociatedObject(self, &labelEmptyCategoryStatic);
}

@end
